package com.example.texted.sql;

import com.google.common.base.Joiner;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringJoiner;
import java.util.stream.Collectors;

public class DO {
    public static void main(String[] args) {
        System.out.println(Arrays.toString(args));
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("select * from t");
        ArrayList<String> strings = new ArrayList<>();
        String collect1 = strings.stream().collect(Collectors.joining(" and ", " where ", ""));
        if (strings.isEmpty()){
            collect1="";
        }
        System.out.println(collect1);
        strings.add("id=:id");
        strings.add("name=:name");
        strings.add("pwd=:pwd");
        String collect = strings.stream().collect(Collectors.joining(" and ", " where ", ""));
        System.out.println(collect);
        StringJoiner stringJoiner = new StringJoiner(" and ", " where ", "").setEmptyValue("");
        System.out.println(stringJoiner);
        stringJoiner.add("id=:id");
        stringJoiner.add("name=:name");
        stringJoiner.add("pwd=:pwd");
        System.out.println(stringJoiner);
    }
}
